unit dmda_Stuff;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dmModule, FR_DSet, FR_DBSet, DB, ADODB, Gauges;

type
  Tdtmda_Stuff = class(TdtmModule)
    adsMasterdyeID: TStringField;
    adsMasterdyeName: TStringField;
    adsMasterSpellHelp: TStringField;
    adsMasterKindID: TStringField;
    adsMasterKindName: TStringField;
    adsMasterGroupID: TStringField;
    adsMasterMainUnitID: TStringField;
    adsMasterMainUnitName: TStringField;
    adsMasterAssUnitID: TStringField;
    adsMasterAssUnitName: TStringField;
    adsMasterConvertRate: TBCDField;
    adsMasterStockUnitID: TStringField;
    adsMasterStockUnitName: TStringField;
    adsMasterStorageUnitID: TStringField;
    adsMasterStorageUnitName: TStringField;
    adsMasterSaleUnitID: TStringField;
    adsMasterSaleUnitName: TStringField;
    adsMasterLowerStock: TBCDField;
    adsMasterUpperStock: TBCDField;
    adsMasterSafeStock: TBCDField;
    adsMasterSafeTerm: TBCDField;
    adsMasterPriceMethod: TStringField;
    adsMasterReferenceCost: TBCDField;
    adsMasterNewCost: TBCDField;
    adsMasterDefaultStockID: TStringField;
    adsMasterABCKind: TWordField;
    adsMasterHasBatchNo: TBooleanField;
    adsMasterHasSale: TBooleanField;
    adsMasterHasInspect: TBooleanField;
    adsMasterHasSafeTerm: TBooleanField;
    adsMasterHasUse: TBooleanField;
    adsMasterHasStop: TBooleanField;
    adsMasterHasSysdefine: TBooleanField;
    adsMasterHasDefault: TBooleanField;
    adsMasterHasCheck: TBooleanField;
    adsMasterChecker: TStringField;
    adsMasterCheckTime: TDateTimeField;
    adsMasterWriter: TStringField;
    adsMasterWriteTime: TDateTimeField;
    adsMasterModifier: TStringField;
    adsMasterModifyTime: TDateTimeField;
    adsMasterRemark: TStringField;
    adsMasterStoper: TStringField;
    adsMasterStopDate: TDateTimeField;
    adsMasterStopMemo: TStringField;
    res_Unit: TADODataSet;
    res_UnitGroup: TADODataSet;
    adsMasterfibreStuff: TBooleanField;
    adsMasterOrderPrice: TBCDField;
    adsMasterBatchQty: TBCDField;
    adsMasterQtyMax: TBCDField;
    adsMasterQtyMin: TBCDField;
    adsMasterProEquCode: TStringField;
    adsMasterHasCheckInStock: TBooleanField;
    adsMasterPOHighPrcmnyType: TStringField;
    adsMasterPOHighPrice: TBCDField;
    adsMasterprofitRate: TBCDField;
    adsMasterSalePrice: TBCDField;
    adsMasterSaleLowPrice: TBCDField;
    adsMasterPicType: TStringField;
    adsMasterNodeCheck: TBooleanField;
    adsMasterCompactType: TStringField;
    adsMasterMassType: TStringField;
    adsMasterBreedID: TStringField;
    adsMasterClassID: TStringField;
    adsStuffType: TADODataSet;
    adsMasterRuleChildID: TStringField;
    adsMasterCompanyID: TStringField;
    res_BaseInfo: TADODataSet;
    adsMasterStuffCode: TStringField;
    adsMasterOutName: TStringField;
    adsMasterContent: TBCDField;
    adsMasterProperty: TStringField;
    adsMasterdirection: TStringField;
    adsMasterdifficult: TStringField;
    adsMasterYardGram: TBCDField;
    adsMasterMaterialID: TStringField;
    adsMasterdyeDeal: TBCDField;
    adsMasterdyeChroma: TBCDField;
    adsMasterActualYardGram: TBCDField;
    adsMasterMinOrderCnt: TBCDField;
    adsMasterSpecs: TStringField;
    adsMasterSpecsNum: TBCDField;
    adsMasterSpecSort: TStringField;
    adsMasterMaterialName: TStringField;
    adsMasterBgOneNetKg: TFloatField;
    adsMasterStuffKind: TStringField;
    adsMasterDNumber: TFloatField;
    adsMasterRecipeStuffCode: TStringField;
    adsMasterProUnitID: TStringField;
    adsMasterEditStuffID: TStringField;
    adsMasterEditStuffCode: TStringField;
    adsMasterEditStuffName: TStringField;
    adsMasterEditSpecsNum: TFloatField;
    adsMasterEditSpecs: TStringField;
    adsMasterEditSpecSort: TStringField;
    adsMasterEditSpellHelp: TStringField;
    adsMasterEditCompanyID: TStringField;
    adsMasterEditColorID: TStringField;
    adsMasterEditClassID: TStringField;
    adsMasterEditKindID: TStringField;
    adsMasterEditPropertyID: TStringField;
    adsMasterEditMaterialID: TStringField;
    adsMasterEditfibreStuff: TBooleanField;
    adsMasterEditOrderPrice: TFloatField;
    adsMasterEditOutName: TStringField;
    adsMasterEditContent: TFloatField;
    adsMasterEditProperty: TStringField;
    adsMasterEditdirection: TStringField;
    adsMasterEditdifficult: TStringField;
    adsMasterEditYardGram: TFloatField;
    adsMasterEditActualYardGram: TFloatField;
    adsMasterEditdyeDeal: TFloatField;
    adsMasterEditdyeChroma: TFloatField;
    adsMasterEditGroupID: TStringField;
    adsMasterEditMainUnitID: TStringField;
    adsMasterEditAssUnitID: TStringField;
    adsMasterEditConvertRate: TFloatField;
    adsMasterEditStockUnitID: TStringField;
    adsMasterEditStorageUnitID: TStringField;
    adsMasterEditSaleUnitID: TStringField;
    adsMasterEditLowerStock: TFloatField;
    adsMasterEditUpperStock: TFloatField;
    adsMasterEditSafeStock: TFloatField;
    adsMasterEditDefaultStockID: TStringField;
    adsMasterEditABCKind: TWordField;
    adsMasterEditHasBatchNo: TBooleanField;
    adsMasterEditBatchQty: TFloatField;
    adsMasterEditQtyMax: TFloatField;
    adsMasterEditQtyMin: TFloatField;
    adsMasterEditProEquCode: TStringField;
    adsMasterEditHasInspect: TBooleanField;
    adsMasterEditHasCheckInStock: TBooleanField;
    adsMasterEditHasSafeTerm: TBooleanField;
    adsMasterEditSafeTerm: TFloatField;
    adsMasterEditPOHighPrcmnyType: TStringField;
    adsMasterEditPOHighPrice: TFloatField;
    adsMasterEditReferenceCost: TFloatField;
    adsMasterEditNewCost: TFloatField;
    adsMasterEditProfitRate: TFloatField;
    adsMasterEditHasSale: TBooleanField;
    adsMasterEditSalePrice: TFloatField;
    adsMasterEditSaleLowPrice: TFloatField;
    adsMasterEditPriceMethod: TStringField;
    adsMasterEditPicType: TStringField;
    adsMasterEditPhoto: TBlobField;
    adsMasterEditNodeCheck: TBooleanField;
    adsMasterEditCompactType: TStringField;
    adsMasterEditMassType: TStringField;
    adsMasterEditWriter: TStringField;
    adsMasterEditWriteTime: TDateTimeField;
    adsMasterEditModifier: TStringField;
    adsMasterEditModifyTime: TDateTimeField;
    adsMasterEditRemark: TStringField;
    adsMasterEditHasSysDefine: TBooleanField;
    adsMasterEditHasDefault: TBooleanField;
    adsMasterEditHasUse: TBooleanField;
    adsMasterEditHasStop: TBooleanField;
    adsMasterEditHasCheck: TBooleanField;
    adsMasterEditChecker: TStringField;
    adsMasterEditCheckTime: TDateTimeField;
    adsMasterEditStoper: TStringField;
    adsMasterEditStopDate: TDateTimeField;
    adsMasterEditStopMemo: TStringField;
    adsMasterEditBgOneNetKg: TFloatField;
    adsMasterEditMinOrderCnt: TFloatField;
    adsMasterEditDNumber: TFloatField;
    adsMasterEditStuffKind: TStringField;
    adsMasterEditRecipeStuffCode: TStringField;
    adsMasterEditProUnitID: TStringField;
    adsMasterEditres_MainUnitName: TStringField;
    adsMasterEditres_AssUnitName: TStringField;
    adsMasterEditres_StockUnitName: TStringField;
    adsMasterEditres_StorageUnitName: TStringField;
    adsMasterEditres_SaleUnitName: TStringField;
    adsMasterEditres_UnitGroupName: TStringField;
    adsMasterEditres_KindName: TStringField;
    adsMasterEditStuffEngName: TStringField;
    adsMasterStuffEngName: TStringField;
    adsMasterEditAvgPrice: TFloatField;
    adsMasterAvgPrice: TFloatField;
    adsMasterEditStuffType: TStringField;
    res_StuffType: TADODataSet;
    procedure adsMasterNewRecord(DataSet: TDataSet);
    procedure adsMasterEditStuffNameChange(Sender: TField);
    procedure adsMasterEditKindIDChange(Sender: TField);
  private
    { Private declarations }
  protected
    procedure ModuleInit;override; 
  public
    { Public declarations }
    FKindID: string;
    FExtendField: string;
    procedure OpenEditDataSet; override;
  end;

var
  dtmda_Stuff: Tdtmda_Stuff;

implementation

uses uConst, uShare, uMsgBox, uGlobal, uSQL;

{$R *.dfm}

{ Tdtmda_Stuff }

procedure Tdtmda_Stuff.ModuleInit;
begin
  inherited;
  FUniqueTable := tbda_Stuff;
end;

procedure Tdtmda_Stuff.adsMasterNewRecord(DataSet: TDataSet);
begin
  inherited;
  if FKindID <> '' then
  begin
    DataSet.FieldByName('KindID').ReadOnly := False;
    DataSet.FieldByName('KindID').AsString := FKindID;
  end;
  DataSet.FieldByName('CompanyID').ReadOnly := False;
  DataSet.FieldByName('CompanyID').AsString := SysInfo.Company;
end;

procedure Tdtmda_Stuff.OpenEditDataSet;
begin
  FMasterEditTable := 'da_Stuff';
  FMasterKeyField := 'StuffID';
  inherited;

end;

procedure Tdtmda_Stuff.adsMasterEditStuffNameChange(Sender: TField);
begin
  inherited;
  if adsMasterEdit.State in [dsInsert, dsEdit] then
  begin
    adsMasterEdit.FieldByName(flSpellHelp).AsString :=
      GetHzPy(adsMasterEdit.FieldByName(flStuffName).AsString);
  end;
end;

procedure Tdtmda_Stuff.adsMasterEditKindIDChange(Sender: TField);
//var
  //StrStuffTypeCode, StuffCode: string;
begin
  inherited;
  {if (adsMasterEdit.State in [dsInsert, dsEdit]) and (Sender.AsString<>'') then
  begin
    if (adsMasterEdit.FieldByName('ClassID').AsString='4') then
    begin
      StrStuffTypeCode := fsExecSQL('Select Code from V_da_StuffType where ID=' + QuotedStr(Sender.AsString));
      adsMasterEdit.FieldByName('StuffCode').ReadOnly := False;
      adsMasterEdit.FieldByName('StuffCode').AsString :=
        uShare.GetMaxOrderID('da_Stuff', 'StuffCode', StrStuffTypeCode, 'ClassID=4', 4);
    end;
  end; }
end;

end.
